#!/usr/bin/env python
# -*- encoding: utf-8 -*-
"""
主题: 解析简单的XML数据
问题: 你想从一个简单的XML文档中提取数据。
提示 : 
"""

from urllib.request import urlopen
from xml.etree.ElementTree import parse

def recipe1():
    u = urlopen('http://planet.python.org/rss20.xml')
    doc = parse(u)

    # Extract and output tags of interest
    for item in doc.iterfind('channel/item'):
        print(f"{item.findtext('title') = }")
        print(f"{item.findtext('pubDate') = }")
        print(f"{item.findtext('link') = }")
        print()

    print(f"{doc = }")
    e = doc.find('channel/title')
    print(f"{e = }")
    print(f"{e.tag = }")
    print(f"{e.text = }")

def main():
    print('recipe1'.center(20, '*'))
    recipe1()


if __name__ == '__main__':
    main()